<template>
  <z-paging ref="pagingRef" @query="queryList" v-model="list">
    <template #top>
      <view style="height: 100px"></view>
    </template>
    <view v-for="(item,index) in list" :key="index" @click="toDetail(item)">
      <InquiryItem :inquiry-item="item"></InquiryItem>
    </view>
  </z-paging>
</template>

<script setup lang="ts">

import {ref} from "vue";
import api from "@/api";
import InquiryItem from "@/components/common/item/InquiryItem.vue";


const pagingRef = ref()
const list = ref([])

const andParams = ref({})
const orParams = ref({})
const orderParams = ref({
  createTime: 2
})

const toDetail = (item: any) => {
  uni.navigateTo({
    url: '/pages/patient/inquiry/detail?inquiryInfo=' + encodeURIComponent(JSON.stringify(item))
  })
}

const queryList = (pageNo: any, pageSize: any) => {
  api.inquiry.list({
    pageNo: pageNo,
    pageSize: pageSize,
    andParams: JSON.stringify(andParams.value),
    orParams: JSON.stringify(orParams.value),
    orderParams: JSON.stringify(orderParams.value),
  }).then(res => {
    if (res && res.data.code === 0) {
      let tmp = res.data.data.records
      Object.keys(tmp).forEach(key => {
        tmp[key].images = JSON.parse(tmp[key].images)
      })
      console.log(tmp)
      pagingRef.value.complete(tmp);
    }
  })
}

</script>

<style scoped>

</style>